<?
include_once("/home/gru/public_html_dev/lib/common.php");
include_once("/home/gru/public_html_dev/lib/cDB.php");
include_once("/home/gru/public_html_dev/lib/cDAO.php");


$db= new cDB();
$dao = new cDAO($db->getCon());

//-----------------------------------------------------------------------------
// 쿠폰 검색용 fulltext 업데이트
//-----------------------------------------------------------------------------
$opt = "";
$q  = " SELECT * FROM coupon $opt";

$arr = $dao->getSheet($q);
if($arr==NULL)exit;


foreach($arr as $i=>$v){
	$id		= $v['id'];
	$pid	= $v['pid'];
	$domain	= $v['domain'];
	$area1	= $v['area1'];
	$area2	= $v['area2'];
	$name	= $v['name'];
	
	$category	= $v['category'];
	$description	= $v['description'];
	$shop_name	= $v['shop_name'];	
	
	
	$sql = "select NAME1,NAME2 from _area_code where CODE1 like '$area1' and CODE2 like '$area2'";
	$arrArea = $dao->getRow($sql);
	
	$sql = "select name from _meta_site where domain = '$domain'";
	$metaName = $dao->getCell($sql);
		
	$fulltext = $domain."|".$metaName."|".$name."|".$category."|".$shop_name."|".$arrArea['NAME1']."|".$arrArea['NAME2'];
	
	$qu = " UPDATE coupon SET sData = '$fulltext' WHERE id = $id";
	debug_flush($qu);
	$dao->query($qu);
	
}

$db->close();
?>
